package com.frank.biz.csxstz.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.biz.csxstz.domain.BizCsxstz;
import com.frank.biz.csxstz.service.IBizCsxstzService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 举报信息Controller
 * 
 * @author frank
 * @date 2024-09-10
 */
@Controller
@RequestMapping("/biz/csxstz")
public class BizCsxstzController extends BaseController
{
    private String prefix = "biz/csxstz";

    @Autowired
    private IBizCsxstzService bizCsxstzService;

    @RequiresPermissions("biz:csxstz:view")
    @GetMapping()
    public String csxstz()
    {
        return prefix + "/csxstz";
    }

    /**
     * 查询举报信息列表
     */
    @RequiresPermissions("biz:csxstz:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizCsxstz bizCsxstz)
    {
        startPage();
//        bizCsxstz.setCreateBy(getUserId());
        bizCsxstz.setCreateBy(getLoginName());
        List<BizCsxstz> list = bizCsxstzService.selectBizCsxstzList(bizCsxstz);
        return getDataTable(list);
    }

    /**
     * 导出举报信息列表
     */
    @RequiresPermissions("biz:csxstz:export")
    @Log(title = "举报信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizCsxstz bizCsxstz)
    {
        bizCsxstz.setCreateBy(getLoginName());
        List<BizCsxstz> list = bizCsxstzService.selectBizCsxstzList(bizCsxstz);
        ExcelUtil<BizCsxstz> util = new ExcelUtil<BizCsxstz>(BizCsxstz.class);
        return util.exportExcel(list, "举报信息数据");
    }

    /**
     * 新增举报信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存举报信息
     */
    @RequiresPermissions("biz:csxstz:add")
    @Log(title = "举报信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizCsxstz bizCsxstz)
    {
        bizCsxstz.setCreateBy(getLoginName());
        return toAjax(bizCsxstzService.insertBizCsxstz(bizCsxstz));
    }

    /**
     * 修改举报信息
     */
    @RequiresPermissions("biz:csxstz:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BizCsxstz bizCsxstz = bizCsxstzService.selectBizCsxstzById(id);
        mmap.put("bizCsxstz", bizCsxstz);
        return prefix + "/edit";
    }

    /**
     * 修改保存举报信息
     */
    @RequiresPermissions("biz:csxstz:edit")
    @Log(title = "举报信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizCsxstz bizCsxstz)
    {
        bizCsxstz.setUpdateBy(getLoginName());
        return toAjax(bizCsxstzService.updateBizCsxstz(bizCsxstz));
    }

    /**
     * 删除举报信息
     */
    @RequiresPermissions("biz:csxstz:remove")
    @Log(title = "举报信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizCsxstzService.deleteBizCsxstzByIds(ids));
    }
}
